using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using NUnit.Framework;

namespace ProjectEuler.Core
{
    public class Problem29 : IProjectEulerProblem
    {
        protected IEnumerable<BigInteger> GetAllIntegerCombination(int min, int max)
        {
            for(int a=min;a<=max;a++)
            {
                for(int b=min;b<=max;b++)
                {
                    yield return BigInteger.Pow(a, b);
                }
            }
        }

        public int Number
        {
            get { return 29; }
        }

        public string Description
        {
            get { return "How many distinct terms are in the sequence generated by a^b for 2<= a<= 100 and 2<= b<= 100?"; }
        }

        public string Answer
        {
            get { return GetAllIntegerCombination(2, 100).Distinct().Count().ToString(); }
        }
    }

    [TestFixture]
    public class Problem29Tests : Problem29
    {
        [Test]
        public void A_and_B_between_2_and_5_should_have_15_distinct_terms()
        {
            Assert.AreEqual(15, GetAllIntegerCombination(2, 5).Distinct().Count());
        }
    }
}